import { kgjHttp as http } from '@/services/http';
import type { OrderResult, OrderReqParam, CreateOrderDto, UpdateOrderDto } from '@/types/api/crm-kgj/order';
import type { SortAndLimit, ListResult } from '@/types/api/common';

/** 获取订单列表 */
export const getOrderList = (payload: { data: OrderReqParam; params: SortAndLimit }) =>
  http<ListResult<OrderResult>, OrderReqParam, SortAndLimit>({
    url: '/api/order/list',
    method: 'post',
    ...payload
  });

/** 创建订单 */
export const createOrder = (data: CreateOrderDto) =>
  http({
    url: '/api/order/add',
    method: 'post',
    data
  });
/** 抖店订单绑定手机号 */
export const createDouOrder = (data: { trade_no: string; mobile: string }) =>
  http({
    url: '/api/order/bind/mobile',
    method: 'post',
    data
  });
/** 更新订单 */
export const updateOrder = (data: UpdateOrderDto) =>
  http({
    url: '/api/order/edit',
    method: 'post',
    data
  });
/** 订单退款 */
export const refundOrder = (data: { trade_no: number }) =>
  http({
    url: '/api/order/refund',
    method: 'post',
    data
  });

/** 获取订单详情 */
export const getOrderDetail = (params: { no: number }) =>
  http({
    url: '/api/order/detail',
    method: 'get',
    params
  });

/** 订单汇总信息 */
export const getOrderSummary = (data: { start_time: number; end_time: number }) =>
  http({
    url: '/api/gold-crm/order/summary',
    method: 'post',
    data
  });

/** 订单每日汇总信息 */
export const getOrderDaysummary = (data: { start_time: number; end_time: number }) =>
  http({
    url: '/api/gold-crm/order/daysummary',
    method: 'post',
    data
  });
